package com.vdong.ai.service.impl;

import com.vdong.ai.http.PostKeDaXunFeiServiceHttpClient;
import com.vdong.ai.service.VoiceHttpClientService;
import com.vdong.ai.util.KeDaXunFeiSecret;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: liangwei
 */
@Service
public class VoiceHttpClientServiceImpl implements VoiceHttpClientService {

    @Autowired
    PostKeDaXunFeiServiceHttpClient postKeDaXunFeiServiceHttpClient;

    @Override
    public String VoiceHttpClient(String fileData, String appid, String appkey) {

        fileData = "data=" + fileData;
        long time = System.currentTimeMillis() / 1000;
        String curTime = String.valueOf(time);
        String xParamBase64 = KeDaXunFeiSecret.getBase64(KeDaXunFeiSecret.xParam);
        String token = appkey + curTime + xParamBase64 + fileData;
        String xCheckSum = KeDaXunFeiSecret.md5Encode(token);
        return postKeDaXunFeiServiceHttpClient.AiVoice(fileData, appid, curTime, xParamBase64, xCheckSum, "keep-alive");


    }
}
